package il.technion.cs236369.webserver.typeHandlers;

import java.util.HashMap;

public class Session {

	private HashMap<String, Object> params = null;

	public Session()
	{
		params = new HashMap<String, Object>();
	}
	
	/**
	 * sets value to be associated with key throughout the session lifetime.
	 * 
	 * @param key
	 * @param value
	 */
	public void set(String key, Object value)
	{
		params.put(key, value);
	}

	/**
	 *  gets a pre-saved value or null if name not found.
	 *  
	 * @param key
	 * @return value associated with key or null if not found
	 */
	public Object get(String key)
	{
		return params.get(key);
	}
	
	/**
	 * invalidates the session and frees all data associated with it.
	 */
	public void invalidate()
	{
		params.clear();
	}

	public boolean isEmpty()
	{
		return params.isEmpty();
	}

}
